package com.ksu.manager.service.impl;

import java.util.Date;
import java.util.List;

import com.ksu.manager.dao.IProductDAO;
import com.ksu.manager.model.Product;
import com.ksu.manager.service.IProductService;

public class ProductServiceImpl implements IProductService {

	private IProductDAO productDAO;
	public IProductDAO getProductDAO() {
		return productDAO;
	}

	public void setProductDAO(IProductDAO productDAO) {
		this.productDAO = productDAO;
	}

	public void add(Product product) {
		product.setStatTime(new Date());
		productDAO.create(product);

	}

	public void del(Product product) {
		productDAO.del(product);
	}

	public List<Product> queryList(Product product) {
		return productDAO.queryList(product);
	}

	public List<Product> queryListByName(Product product) {
		return productDAO.queryListByName(product);
	}

	@Override
	public void mod(Product product) {
		product.setStatTime(new Date());
		productDAO.update(product);
		
	}

	@Override
	public Product queryProductById(Product product) {
		List<Product> productList = productDAO.queryList(product);
		if(productList!=null && productList.size()>0){
			product = productList.get(0);
		}
		return product;
	}
	

}
